<template xmlns:v-clipboard="http://www.w3.org/1999/xhtml">
  <div>
    <div align="center">
    <el-card style="width: 1500px" align="center">
      <el-row>

        <el-col :span="7">
        <el-input placeholder="请输入查询内容" v-model="quaryInfo.quary" clearable @clear="getCustomMessage"></el-input>
        </el-col>
        <el-col  :span="1">
          <el-button type="primary" icon="el-icon-search" @click="getCustomMessage">搜索</el-button>
        </el-col>
      </el-row>
    <el-row>
      <el-col :span="4"></el-col>
      <el-col>
    <el-table :data="customlist" border stripe style="width: 100%" align="center" height="700">
      <el-table-column prop="customID" v-if="show=false"></el-table-column>
    <el-table-column prop="date" label="日期" width="200%"></el-table-column>
    <el-table-column prop="customName" label="姓名" width="100%"></el-table-column>
    <el-table-column prop="province" label="省份" width="100%"></el-table-column>
    <el-table-column prop="city" label="市区" width="100%"></el-table-column>
    <el-table-column prop="address" label="地址" width="300%"></el-table-column>
    <el-table-column prop="postNum" label="邮编" width="100%"></el-table-column>
    <el-table-column  label="操作" width="500">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row.customID,scope.row.date,scope.row.customName,scope.row.province,scope.row.city,scope.row.address,scope.row.postNum)" type="primary" icon="el-icon-view">查看</el-button>
        <el-button type="primary" icon="el-icon-edit"
                   @click="editdialogVisible(scope.row.customID,scope.row.date,scope.row.customName,scope.row.province,scope.row.city,scope.row.address,scope.row.postNum)">
          编辑</el-button>
        <el-button type="primary" icon="el-icon-upload" @click="uploaddialogVisiable(scope.row.customID)">上传审核资料</el-button>
        <el-button type="danger" icon="el-icon-delete" @click="open(scope.row.customID)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>

      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="quaryInfo.PageNum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="quaryInfo.PageSize"
        layout=" sizes, prev, pager, next, total, jumper"
        :total="total">
      </el-pagination>

        <el-dialog
          title="编辑客户基础信息"
          :visible.sync="EditdialogVisible"
          width="30%" @close="EditdialogVisible = false">
          <el-form :model="EditFrom" label-width="70px">
            <el-form-item label="日期：" >
                <el-date-picker type="date" placeholder="选择日期"  value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width: 100%;" v-model="EditFrom.date"></el-date-picker>
            </el-form-item>
            <el-form-item label="姓名：">
              <el-input v-model="EditFrom.CustomName"></el-input>
            </el-form-item>
            <el-form-item label="省份：">
              <el-input v-model="EditFrom.Province"></el-input>
            </el-form-item>
            <el-form-item label="市区：">
              <el-input v-model="EditFrom.City"></el-input>
            </el-form-item>
            <el-form-item label="地址：">
              <el-input v-model="EditFrom.Address"></el-input>
            </el-form-item>
            <el-form-item label="邮编：">
              <el-input v-model="EditFrom.PostNum"></el-input>
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
           <el-button type="primary" @click="confirmUpdate">确认修改</el-button>
            <el-button @click="EditdialogVisible = false">取 消</el-button>
          </span>
        </el-dialog>

        <el-dialog
          title="查看客户基础信息"
          :visible.sync="showdialogVisible"
          width="30%" @close="showdialogVisible = false">
          <el-form :model="EditFrom" label-width="70px">
            <el-form-item label="日期：" >
              <el-input v-model="EditFrom.date" disabled></el-input>
            </el-form-item>
            <el-form-item label="姓名：">
              <el-input v-model="EditFrom.CustomName" disabled></el-input>
            </el-form-item>
            <el-form-item label="省份：">
              <el-input v-model="EditFrom.Province" disabled></el-input>
            </el-form-item>
            <el-form-item label="市区：">
              <el-input v-model="EditFrom.City" disabled></el-input>
            </el-form-item>
            <el-form-item label="地址：">
              <el-input v-model="EditFrom.Address" disabled></el-input>
            </el-form-item>
            <el-form-item label="邮编：">
              <el-input v-model="EditFrom.PostNum" disabled></el-input>
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
           <el-button type="primary" @click="handlecopy" v-clipboard:copy="message">复制</el-button>
            <el-button @click="showdialogVisible = false">取 消</el-button>
          </span>
        </el-dialog>
        <el-dialog
          title="审核资料录入"
          :visible.sync="ShenhedialogVisible"
          width="30%" @close="ShenhedialogVisible = false">
          <el-form :model="ShenheForm" label-width="90px">
            <el-form-item label="车价：" >
              <el-input v-model="ShenheForm.CarPrice"></el-input>
            </el-form-item>
            <el-form-item label="首付金额：">
              <el-input v-model="ShenheForm.Prepay"></el-input>
            </el-form-item>
            <el-form-item label="贷款金额：">
              <el-input v-model="ShenheForm.Dai_kuan_jin_e"></el-input>
            </el-form-item>
            <el-form-item label="综合利率：">
              <el-input v-model="ShenheForm.Zong_he_li_lv"></el-input>
            </el-form-item>
            <el-form-item label="贷款年数：">
              <el-input v-model="ShenheForm.Dai_kuan_nian_shu"></el-input>
            </el-form-item>
            <el-form-item label="月供：">
              <el-input v-model="ShenheForm.Yue_gong"></el-input>
            </el-form-item>
            <el-form-item label="贷款类型：">
              <el-select v-model="ShenheForm.Dai_kuan_lei_xing" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="婚姻状况">
              <el-radio-group v-model="ShenheForm.Marriage">
              <el-radio label="1" value="1">已婚</el-radio>
              <el-radio label="2" value="2">未婚</el-radio>
              <el-radio label="3" value="3">离异</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="comfirmUploadShenhe">确定</el-button>
           <el-button type="primary" @click="UploadEvidence">上传相关佐证</el-button>
            <el-button @click="ShenhedialogVisible = false">取 消</el-button>
          </span>
        </el-dialog>

        <el-dialog
          title="相关佐证上传"
          :visible.sync="zuozhendialogVisible"
          width="80%" @close="handleclose"
          top="5vh">
          <el-form :model="ShenheForm" label-width="90px">
            <el-form-item >
              <el-row :gutter="20">
              <el-col :span="8">
              <el-card style="padding: 40px;" >
                <el-upload
                  :auto-upload="false"
                  :action="actionURL"
                  list-type="picture-card"
                  ref="upload"
                  :on-remove="handleRemove"
                  :limit = "1"
                  :on-change="handleEditChange"
                  :class="{hide:hideUploadEdit}"
                  :file-list="confirmList" multiple
                  :before-upload="beforeUpload"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
                <span>贷款人身份证正面（国徽面）</span>
              </el-card>
              </el-col>
              <el-col :span="8">
                <el-card style="padding: 40px;">
                  <el-upload
                    ref="upload1"
                    :auto-upload="false"
                    :action="actionURL1"
                    list-type="picture-card"
                    :on-remove="handleRemove1"
                    :limit = "1"
                    :on-change="handleEditChange1"
                    :class="{hide1:hideUploadEdit1}"
                    :before-upload="beforeUpload">
                    <i class="el-icon-plus"></i>
                  </el-upload>
                  <span>担保人身份证正面</span>
                </el-card>
              </el-col>
              <el-col :span="8">
                <el-card style="padding: 40px;">
                  <el-upload
                    ref="upload2"
                    :auto-upload="false"
                    :action="actionURL2"
                    list-type="picture-card"
                    :on-remove="handleRemove2"
                    :limit = "1"
                    :on-change="handleEditChange2"
                    :class="{hide2:hideUploadEdit2}"
                    :before-upload="beforeUpload">
                    <i class="el-icon-plus"></i>
                  </el-upload>
                  <span>合同照</span>
                </el-card>
              </el-col>
              </el-row>
            </el-form-item>
            <el-form-item>
              <el-row :gutter="20">
              <el-col :span="8">
              <el-card style="padding: 40px;">
                <el-upload
                  ref="upload3"
                  :auto-upload="false"
                  :action="actionURL3"
                  list-type="picture-card"
                  :on-remove="handleRemove3"
                  :limit = "1"
                  :on-change="handleEditChange3"
                  :class="{hide3:hideUploadEdit3}"
                  :before-upload="beforeUpload">
                  <i class="el-icon-plus"></i>
                </el-upload>
                <span>贷款人身份证反面（人像面）</span>
              </el-card>
              </el-col>
              <el-col :span="8">
                <el-card style="padding: 40px;">
                  <el-upload
                    ref="upload4"
                    :auto-upload="false"
                    :action="actionURL4"
                    list-type="picture-card"
                    :on-remove="handleRemove4"
                    :limit = "1"
                    :on-change="handleEditChange4"
                    :class="{hide4:hideUploadEdit4}"
                    :before-upload="beforeUpload">
                    <i class="el-icon-plus"></i>
                  </el-upload>
                  <span>担保人身份证反面</span>
                </el-card>
              </el-col>
              <el-col :span="8">
                <el-card style="padding: 40px;">
                  <el-upload
                    ref="upload5"
                    :auto-upload="false"
                    :action="actionURL5"
                    list-type="picture-card"
                    :on-remove="handleRemove5"
                    :limit = "1"
                    :on-change="handleEditChange5"
                    :class="{hide5:hideUploadEdit5}"
                    :before-upload="beforeUpload">
                    <i class="el-icon-plus"></i>
                  </el-upload>
                  <span>房产证照片</span>
                </el-card>
              </el-col>
              </el-row>
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
            <el-button align="center" type="primary" @click="comfirmUpload">立即上传</el-button>
            <el-button @click="handleclose">取 消</el-button>
          </span>
        </el-dialog>
      </el-col>
    </el-row>
    </el-card>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        hideUploadEdit: false,
        hideUploadEdit1: false,
        hideUploadEdit2: false,
        hideUploadEdit3: false,
        hideUploadEdit4: false,
        hideUploadEdit5: false,
        quaryInfo:{
          quary:'',
          PageNum:1,
          PageSize:10
        },
        customlist:[],
        total:0,
        EditdialogVisible : false,
        showdialogVisible: false,
        ShenhedialogVisible:false,
        zuozhendialogVisible:false,
        dialogImageUrl: '',
        dialogVisible: false,
        EditFrom:{
          customID:'',
          date:'',
          CustomName:'',
          Province:'',
          City:'',
          Address:'',
          PostNum:''
        },
        ShenheForm:{
          CustomID:'',
          CarPrice:'',
          Prepay:'',
          Dai_kuan_jin_e:'',
          Zong_he_li_lv:'',
          Dai_kuan_nian_shu:'',
          Yue_gong:'',
          Dai_kuan_lei_xing:'',
          Marriage:'',


        },
        options:[{
          value: '1',
          label: '自有资金'
        }, {
          value: '2',
          label: '联合贷款'
        }],
        message:'',
        confirmList:[

        ],
        defaultUrl:'http://127.0.0.1:8080/neishen/uploadImage?CustomID=',
        baseUrl:'http://127.0.0.1:8080/neishen/uploadImage?CustomID=',
        actionURL:'',
        actionURL1:'',
        actionURL2:'',
        actionURL3:'',
        actionURL4:'',
        actionURL5:'',
        CustomID:''
      }
    },
    created(){
      this.getCustomMessage()
    },
    methods:{
      async getCustomMessage(){
      const {data:res}=await this.$http.get('neishen/readNeishen',{params:this.quaryInfo})
        this.customlist = res.Custom
        this.total=res.total
        this.PageSize=res.PageSize
        this.PageNum=res.PageNum
      },
      handleEditChange(file, fileList){
        this.actionURL=this.baseUrl+'&Type='+1
        this.hideUploadEdit = fileList.length >= 1
      },
      handleEditChange1(file, fileList){
        this.actionURL1=this.baseUrl+'&Type='+2
        this.hideUploadEdit1 = fileList.length >= 1
      },
      handleEditChange2(file, fileList){
        this.actionURL2=this.baseUrl+'&Type='+3
        this.hideUploadEdit2 = fileList.length >= 1
      },
      handleEditChange3(file, fileList){
        this.actionURL3=this.baseUrl+'&Type='+4
        this.hideUploadEdit3 = fileList.length >= 1
      },
      handleEditChange4(file, fileList){
        this.actionURL4=this.baseUrl+'&Type='+5
        this.hideUploadEdit4 = fileList.length >= 1
      },
      handleEditChange5(file, fileList){
        this.actionURL5=this.baseUrl+'&Type='+6
        this.hideUploadEdit5 = fileList.length >= 1
      },
      handleclose(){
        this.$refs.upload.clearFiles()
        this.handleRemove(this.$refs.upload.file,this.$refs.upload.fileList)
        this.$refs.upload1.clearFiles()
        this.handleRemove1(this.$refs.upload1.file,this.$refs.upload1.fileList)
        this.$refs.upload2.clearFiles()
        this.handleRemove2(this.$refs.upload2.file,this.$refs.upload2.fileList)
        this.$refs.upload3.clearFiles()
        this.handleRemove3(this.$refs.upload3.file,this.$refs.upload3.fileList)
        this.$refs.upload4.clearFiles()
        this.handleRemove4(this.$refs.upload4.file,this.$refs.upload4.fileList)
        this.$refs.upload5.clearFiles()
        this.handleRemove5(this.$refs.upload5.file,this.$refs.upload5.fileList)
        this.zuozhendialogVisible = false
        this.baseUrl=this.defaultUrl
      },

      handleSizeChange(NewSize){
        this.quaryInfo.PageSize = NewSize
        this.getCustomMessage()

      },
      handleCurrentChange(NewPage){
        this.quaryInfo.PageNum = NewPage
        this.getCustomMessage()
      },
      async editdialogVisible(id,date,name,pro,city,addr,ponu){
        this.EditFrom.customID=id
        this.EditFrom.date=date
        this.EditFrom.CustomName=name
        this.EditFrom.Province=pro
        this.EditFrom.City=city
        this.EditFrom.Address=addr
        this.EditFrom.PostNum=ponu
        this.CustomID=id
        this.EditdialogVisible = true
      },
      confirmUpdate(){
        this.$http.get('neishen/updateByID',{params:this.EditFrom})
        this.$message.success('修改成功!');
        this.EditdialogVisible = false
      },
      comfirmUploadShenhe(){
        this.$http.get('neishen/updateShenheByID',{params:this.ShenheForm})
        this.$message.success('上传成功!');
        this.ShenhedialogVisible = false
      },
      handleClick(id,date,name,pro,city,addr,ponu){
        this.EditFrom.customID=id
        this.EditFrom.date=date
        this.EditFrom.CustomName=name
        this.EditFrom.Province=pro
        this.EditFrom.City=city
        this.EditFrom.Address=addr
        this.EditFrom.PostNum=ponu
        this.message='客户编号：'+id+'\n' +
        '日期：'+date+'\n' +
        '客户姓名：'+name+'\n' +
        '省份：'+pro+'\n' +
        '市区：'+city+'\n' +
        '地址：'+addr+'\n' +
        '邮编：'+ponu
        this.showdialogVisible = true
      },
      handlecopy(){
        this.$message.success('复制成功!')
      },
      open(id) {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http.get('neishen/deleteByID',{params:{customID: id}})
          this.getCustomMessage()
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },


      comfirmUpload(){
        this.$refs.upload.submit();
        this.$refs.upload1.submit();
        this.$refs.upload2.submit();
        this.$refs.upload3.submit();
        this.$refs.upload4.submit();
        this.$refs.upload5.submit();
        this.$message.success("上传成功")
        this.baseUrl=this.defaultUrl
      },
      beforeUpload(file) {
        const isLt4M = file.size / 1024 / 1024 < 4;

        if(!(file.type === 'image/png' || file.type === 'image/gif' || file.type === 'image/jpg' || file.type === 'image/jpeg')) {
          this.$notify.warning({
            title: '警告',
            message: '请上传格式为image/png, image/gif, image/jpg, image/jpeg的图片'
          })
        }
        if (!isLt4M) {
          this.$message.error('上传图片大小不能超过 4MB!');
        }
        return isLt4M;
      },
      UploadEvidence(){
        this.baseUrl=this.baseUrl+this.CustomID
        this.zuozhendialogVisible = true
      },
      uploaddialogVisiable(id){
        this.ShenheForm.CustomID=id
        this.CustomID=id
        this.ShenhedialogVisible=true
      },

      handleRemove(file, fileList){
        this.hideUploadEdit = fileList.length >= 1
      },
      handleRemove1(file, fileList){
        this.hideUploadEdit1 = fileList.length >= 1
      },
      handleRemove2(file, fileList){
        this.hideUploadEdit2 = fileList.length >= 1
      },
      handleRemove3(file, fileList){
        this.hideUploadEdit3 = fileList.length >= 1
      },
      handleRemove4(file, fileList){
        this.hideUploadEdit4 = fileList.length >= 1
      },
      handleRemove5(file, fileList){
        this.hideUploadEdit5 = fileList.length >= 1
      },

    }
  }
</script>
<style>
  .hide .el-upload--picture-card {
    display: none;
  }
  .hide1 .el-upload--picture-card {
    display: none;
  }
  .hide2 .el-upload--picture-card {
    display: none;
  }
  .hide3 .el-upload--picture-card {
    display: none;
  }
  .hide4 .el-upload--picture-card {
    display: none;
  }
  .hide5 .el-upload--picture-card {
    display: none;
  }

</style>
